var t = getApp();

Page({
    data: {
        numText: 1
    },
    onLoad: function(a) {
        var n = this;
        this.setData({
            token: wx.getStorageSync("log")
        }), wx.request({
            url: t.globalData.doctor + "doctor/personal/showconfig",
            data: {
                token: this.data.token
            },
            success: function(t) {
                if (console.log(t), 200 == t.data.code) {
                    var a = t.data.data.config.exchangeRate / 100;
                    n.setData({
                        integral: t.data.data.credit.totalCredit,
                        ruleIntegral: 1 / a,
                        ruleMoney: 1,
                        configId: t.data.data.config.id
                    });
                }
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    goAll: function() {
        this.setData({
            inputText: this.data.integral
        });
    },
    getText: function(t) {
        console.log(t), this.setData({
            inputText: t.detail.value
        });
    },
    gotoChange: function() {
        var a = this;
        parseInt(this.data.inputText) <= 0 || !this.data.inputText ? wx.showToast({
            title: "使用积分要大于0哦",
            icon: "none",
            duration: 2e3
        }) : parseInt(this.data.inputText) > parseInt(this.data.integral) ? wx.showToast({
            title: "超出可用积分",
            icon: "none",
            duration: 2e3
        }) : (wx.showLoading({
            title: "兑换中...",
            mask: !0
        }), this.setData({
            disable: !0
        }), wx.request({
            url: t.globalData.doctor + "doctor/personal/exchangemoney",
            data: {
                token: a.data.token,
                configId: a.data.configId,
                integral: a.data.inputText
            },
            success: function(t) {
                console.log(t), wx.hideLoading(), 200 == t.data.code ? a.setData({
                    successFlag: !0,
                    convertMoney: t.data.data.money / 100
                }) : (a.setData({
                    disable: !1
                }), wx.showToast({
                    title: "系统繁忙，请稍后重试",
                    icon: "none",
                    duration: 2e3
                }));
            },
            fail: function(t) {
                a.setData({
                    disable: !1
                }), wx.showToast({
                    title: "系统繁忙，请稍后重试",
                    icon: "none",
                    duration: 2e3
                });
            }
        }));
    },
    goodBtn: function() {
        this.setData({
            successFlag: !1
        }), wx.navigateBack({
            delta: 1
        });
    }
});